package com.cmf.myproject.controller.boss.problemonline;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cmf.myproject.dal.mybatis.model.ProblemOnline;
import com.cmf.myproject.service.problemOnline.dto.ProblemOnlineAddItemReqDto;
import com.cmf.myproject.service.problemOnline.dto.ProblemOnlineUpdateItemReqDto;
import com.cmf.myproject.service.problemOnline.ProblemOnlineService;
import com.cmf.myproject.service.problemOnline.dto.ProblemOnlineQueryFilter;
import com.system.core.controller.ControllerBase;
import com.system.core.results.ResultBase;
import com.system.core.view.layui.table.TableViewRspDto;

@Controller
@RequestMapping("boss/problem_online")
public class ProblemOnlineController extends ControllerBase {
	@Autowired
	private ProblemOnlineService problemOnlineService;
	
	@RequiresPermissions("problemOnline_topage")
	@RequestMapping(value = "to_page",method = RequestMethod.GET)
	public String toPage() {
		return "/boss/problemOnline/problemOnline-list";
	}
	
	@RequestMapping(value = "query_list",method = RequestMethod.POST)
	@ResponseBody
	public TableViewRspDto<ProblemOnline> problemOnlineQueryList(ProblemOnlineQueryFilter filter) {
		TableViewRspDto<ProblemOnline> rsp = problemOnlineService.problemOnlineList(filter);
		return rsp;
	}
	
	@RequestMapping(value = "get_item_by_key",method = RequestMethod.POST)
	@ResponseBody
	public ProblemOnline problemOnlineGetByPrimaryKey(ProblemOnline problemOnline){
		return problemOnlineService.problemOnlineGetByPrimaryKey(problemOnline);
	}
	
	@RequiresPermissions("problemOnline_add_opt")
	@RequestMapping(value = "add_item",method = RequestMethod.POST)
	@ResponseBody
	public ResultBase problemOnlineAddItem(@Validated ProblemOnlineAddItemReqDto problemOnlineAddItemReqDto) {
		return problemOnlineService.problemOnlineSave(problemOnlineAddItemReqDto);
	}
	
	@RequiresPermissions("problemOnline_edit_opt")
	@RequestMapping(value = "update_item",method = RequestMethod.POST)
	@ResponseBody
	public ResultBase problemOnlineUpdateItem(@Validated ProblemOnlineUpdateItemReqDto problemOnlineUpdateItemReqDto) {
		return problemOnlineService.problemOnlineUpdateByPrimaryKey(problemOnlineUpdateItemReqDto);
	}
	
	@RequiresPermissions("problemOnline_delete_opt")
	@RequestMapping(value = "delete_item",method = RequestMethod.POST)
	@ResponseBody
	public ResultBase problemOnlineDeleteItem(@RequestBody List<Long> keys) {
		return problemOnlineService.problemOnlineDeleteByPrimaryKey(keys);
	}
}
